package com.goldsprite.microhorigame.screens.tests.lightsystem;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL30;
import com.badlogic.gdx.graphics.Texture;
import com.goldsprite.gameframeworks.assets.GameRes;
import com.goldsprite.gameframeworks.screens.GScreen;

public class MultiplyTextureBindTest extends GScreen {
	private AdvancedSpriteBatch batch;
	private Texture playerTexture;
	private Texture lightMapTexture;
	private Texture backgroundTexture;

	public void create() {
		batch = new AdvancedSpriteBatch();
		playerTexture = new Texture(GameRes.Boss_Sample.getPath());
		backgroundTexture = new Texture("sprites/blocks/grass0.png");

		lightMapTexture = new Texture("sprites/white_ball.png");

		// 设置额外纹理
		batch.setExtraTexture(lightMapTexture);
	}

	@Override
	public void render(float delta) {
		Gdx.gl.glClearColor(0, 0, 0, 1);
		Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT);

		batch.begin();
		batch.setProjectionMatrix(getViewport().getCamera().combined);

		// 正常绘制 - 会自动应用光照纹理
		batch.draw(backgroundTexture, 0, 0, getViewSize().x, getViewSize().y);
		batch.draw(playerTexture, 100, 100);
		batch.draw(playerTexture, 300, 200);

		batch.end();
	}

	@Override
	public void dispose() {
		batch.dispose();
		playerTexture.dispose();
		lightMapTexture.dispose();
		backgroundTexture.dispose();
	}
}
